package agent.client.android;

import java.util.GregorianCalendar;
import java.util.TimeZone;
import java.util.logging.Logger;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CalendarView;

public class Da_A_1Activity extends Activity
{
	
	private Logger logger = Logger.getLogger(this.getClass().getName());
	
	CalendarView calendarView;
	
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.da_a1);
	    
	    calendarView = (CalendarView)findViewById(R.id.calendarView1);
	    //calendarView.setMinDate(System.currentTimeMillis());
	    
	    
	    Button button = (Button)findViewById(R.id.da);
	    button.setOnClickListener(buttonListener);
	}
	

	private OnClickListener buttonListener=new OnClickListener() {
		
		public void onClick(View v) {
			
			long startTime=calendarView.getDate();
			long currentTimeMillis=System.currentTimeMillis();
			if( startTime < currentTimeMillis)
				startTime = currentTimeMillis;
			
			GregorianCalendar gregorianCalendar = new GregorianCalendar();
			gregorianCalendar.setTimeInMillis(startTime);
			gregorianCalendar.setTimeZone(TimeZone.getDefault());
			
			String dataTransferObject = gregorianCalendar.getTimeInMillis()+",";
			
			Intent intent=new Intent(Da_A_1Activity.this, Da_A_2Activity.class);
			intent.putExtra("dto", dataTransferObject);
			intent.putExtra("username", (String)getIntent().getExtras().get("username"));
			startActivity(intent);
			
			}
		
	};

}
